<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>接单逻辑处理操作界面</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
    <style>
        .order-card {
            transition: all 0.3s ease;
            border-left: 4px solid #007bff;
            margin-bottom: 15px;
        }
        .order-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        }
        .order-card.pending {
            border-left-color: #ffc107;
        }
        .order-card.confirmed {
            border-left-color: #28a745;
        }
        .order-card.paid {
            border-left-color: #17a2b8;
        }
        .order-card.cancelled {
            border-left-color: #dc3545;
        }
        
        .status-badge {
            font-size: 0.8em;
            padding: 0.25em 0.5em;
        }
        .status-pending { background-color: #ffc107; color: #000; }
        .status-confirmed { background-color: #28a745; color: #fff; }
        .status-paid { background-color: #17a2b8; color: #fff; }
        .status-cancelled { background-color: #dc3545; color: #fff; }
        .status-completed { background-color: #6c757d; color: #fff; }
        
        .payment-status-pending { background-color: #ffc107; color: #000; }
        .payment-status-paid { background-color: #28a745; color: #fff; }
        .payment-status-failed { background-color: #dc3545; color: #fff; }
        
        .notification {
            position: fixed;
            top: 20px;
            right: 20px;
            z-index: 1050;
            min-width: 300px;
        }
        
        .connection-status {
            position: fixed;
            top: 20px;
            left: 20px;
            z-index: 1050;
        }
        
        .stats-card {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }
        
        .action-buttons {
            display: flex;
            gap: 5px;
            flex-wrap: wrap;
        }
        
        .action-buttons .btn {
            font-size: 0.8em;
            padding: 0.25rem 0.5rem;
        }
        
        .order-priority {
            position: absolute;
            top: 10px;
            right: 10px;
            width: 20px;
            height: 20px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.7em;
            font-weight: bold;
        }
        
        .priority-high {
            background-color: #dc3545;
            color: white;
        }
        
        .priority-medium {
            background-color: #ffc107;
            color: #000;
        }
        
        .priority-low {
            background-color: #28a745;
            color: white;
        }
        
        .real-time-indicator {
            animation: pulse 2s infinite;
        }
        
        @keyframes pulse {
            0% { opacity: 1; }
            50% { opacity: 0.5; }
            100% { opacity: 1; }
        }
        
        .order-timer {
            font-size: 0.8em;
            color: #6c757d;
        }
        
        .order-amount {
            font-size: 1.2em;
            font-weight: bold;
            color: #28a745;
        }
        
        .filter-section {
            background-color: #f8f9fa;
            padding: 15px;
            border-radius: 8px;
            margin-bottom: 20px;
        }
        
        .order-details {
            font-size: 0.9em;
            color: #6c757d;
        }
        
        .tenant-info, .landlord-info {
            display: flex;
            align-items: center;
            gap: 8px;
        }
        
        .user-avatar {
            width: 32px;
            height: 32px;
            border-radius: 50%;
            background-color: #007bff;
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.8em;
        }
    </style>
</head>
<body>
    <div class="container-fluid">
        <!-- 连接状态指示器 -->
        <div class="connection-status">
            <div class="alert alert-info" id="connectionStatus">
                <i class="fas fa-circle text-danger"></i> 连接中...
            </div>
        </div>
        
        <!-- 页面标题 -->
        <div class="row mb-4">
            <div class="col-12">
                <h1 class="text-center">
                    <i class="fas fa-handshake text-primary"></i> 接单逻辑处理操作界面
                    <span class="badge bg-success real-time-indicator">实时</span>
                </h1>
            </div>
        </div>
        
        <!-- 统计信息 -->
        <div class="row mb-4">
            <div class="col-md-2">
                <div class="card stats-card">
                    <div class="card-body text-center">
                        <h5 class="card-title">总订单</h5>
                        <h2 id="totalOrders">0</h2>
                    </div>
                </div>
            </div>
            <div class="col-md-2">
                <div class="card stats-card">
                    <div class="card-body text-center">
                        <h5 class="card-title">待接单</h5>
                        <h2 id="pendingAcceptOrders">0</h2>
                    </div>
                </div>
            </div>
            <div class="col-md-2">
                <div class="card stats-card">
                    <div class="card-body text-center">
                        <h5 class="card-title">已接单</h5>
                        <h2 id="acceptedOrders">0</h2>
                    </div>
                </div>
            </div>
            <div class="col-md-2">
                <div class="card stats-card">
                    <div class="card-body text-center">
                        <h5 class="card-title">处理中</h5>
                        <h2 id="processingOrders">0</h2>
                    </div>
                </div>
            </div>
            <div class="col-md-2">
                <div class="card stats-card">
                    <div class="card-body text-center">
                        <h5 class="card-title">已完成</h5>
                        <h2 id="completedOrders">0</h2>
                    </div>
                </div>
            </div>
            <div class="col-md-2">
                <div class="card stats-card">
                    <div class="card-body text-center">
                        <h5 class="card-title">今日收入</h5>
                        <h2 id="todayRevenue">¥0</h2>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 筛选和搜索 -->
        <div class="filter-section">
            <div class="row">
                <div class="col-md-3">
                    <label class="form-label">订单状态</label>
                    <select class="form-select" id="statusFilter">
                        <option value="">所有状态</option>
                        <option value="1">待确认</option>
                        <option value="2">已确认</option>
                        <option value="3">已支付</option>
                        <option value="4">已完成</option>
                        <option value="5">已取消</option>
                    </select>
                </div>
                <div class="col-md-3">
                    <label class="form-label">优先级</label>
                    <select class="form-select" id="priorityFilter">
                        <option value="">所有优先级</option>
                        <option value="high">高优先级</option>
                        <option value="medium">中优先级</option>
                        <option value="low">低优先级</option>
                    </select>
                </div>
                <div class="col-md-3">
                    <label class="form-label">搜索</label>
                    <input type="text" class="form-control" id="searchInput" placeholder="搜索订单号、租客或房东">
                </div>
                <div class="col-md-3">
                    <label class="form-label">操作</label>
                    <div class="d-flex gap-2">
                        <button class="btn btn-primary" onclick="refreshOrders()">
                            <i class="fas fa-sync-alt"></i> 刷新
                        </button>
                        <button class="btn btn-success" onclick="toggleAutoRefresh()">
                            <i class="fas fa-play" id="autoRefreshIcon"></i> <span id="autoRefreshText">自动刷新</span>
                        </button>
                        <button class="btn btn-info" onclick="showBulkActions()">
                            <i class="fas fa-tasks"></i> 批量操作
                        </button>
                    </div>
                </div>
            </div>
        </div>
        
        <!-- 订单列表 -->
        <div class="row">
            <div class="col-12">
                <div class="card">
                    <div class="card-header d-flex justify-content-between align-items-center">
                        <h5><i class="fas fa-list"></i> 待处理订单列表</h5>
                        <div class="d-flex gap-2">
                            <button class="btn btn-sm btn-outline-primary" onclick="sortOrders('time')">
                                <i class="fas fa-clock"></i> 按时间排序
                            </button>
                            <button class="btn btn-sm btn-outline-primary" onclick="sortOrders('amount')">
                                <i class="fas fa-dollar-sign"></i> 按金额排序
                            </button>
                            <button class="btn btn-sm btn-outline-primary" onclick="sortOrders('priority')">
                                <i class="fas fa-exclamation-triangle"></i> 按优先级排序
                            </button>
                        </div>
                    </div>
                    <div class="card-body">
                        <div id="ordersList">
                            <div class="text-center">
                                <div class="spinner-border" role="status">
                                    <span class="visually-hidden">加载中...</span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 通知容器 -->
    <div id="notificationContainer"></div>
    
    <!-- 订单详情模态框 -->
    <div class="modal fade" id="orderDetailModal" tabindex="-1">
        <div class="modal-dialog modal-xl">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">订单详情</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body" id="orderDetailContent">
                    <!-- 订单详情内容 -->
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">关闭</button>
                    <button type="button" class="btn btn-primary" onclick="acceptOrder()">接单</button>
                    <button type="button" class="btn btn-warning" onclick="rejectOrder()">拒绝</button>
                </div>
            </div>
        </div>
    </div>
    
    <!-- 批量操作模态框 -->
    <div class="modal fade" id="bulkActionModal" tabindex="-1">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">批量操作</h5>
                    <button type="button" class="btn-close" data-bs-dismiss="modal"></button>
                </div>
                <div class="modal-body">
                    <div class="mb-3">
                        <label class="form-label">选择操作</label>
                        <select class="form-select" id="bulkAction">
                            <option value="">请选择操作</option>
                            <option value="accept">批量接单</option>
                            <option value="reject">批量拒绝</option>
                            <option value="assign">批量分配</option>
                        </select>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">备注</label>
                        <textarea class="form-control" id="bulkRemark" rows="3" placeholder="请输入操作备注"></textarea>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" onclick="executeBulkAction()">执行</button>
                </div>
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
    <script src="/static/js/order-acceptance.js"></script>
</body>
</html>

